package com.bootdo.imgtext.check.impl;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.bootdo.imgtext.check.CheckService;

public class KpChinaImpl extends CheckService{

	public KpChinaImpl(String url) {
		Document doc = getDoc(url);
		
		Element content = null;
		if (doc != null) {
			content = doc.select("div#article").first();
		} else {
			return;
		}
		
		Elements paragraphs = content.select("p");
		if (paragraphs.size() > 1) {
			String lastParagraph = paragraphs.get(paragraphs.size() - 1).text().trim();
			if (lastParagraph.length() > 4 && lastParagraph.lastIndexOf('）') == lastParagraph.length() - 1) {
				author = lastParagraph.substring(lastParagraph.lastIndexOf('（') + 1, lastParagraph.length() - 1);
			}
		}
		
		Elements imgs = content.select("img[src]");
		checkImgs(imgs);
	}
}
